#include<bits/stdc++.h>
using namespace std;
const int maxn=1e5+5;
int n,m,v,p[maxn],d[maxn],vc,a,l[maxn],r[maxn],L,num=1,k=1;
int main()
{
    freopen("detect.in","r",stdin);
    freopen("detect.out","w",stdout);
    int T;
    cin>>T;
    while(T--)
    {
        memset(l,0,sizeof(l));
        memset(r,0,sizeof(r));
        memset(p,0,sizeof(p));
        int ans=0,k=1,num=1,ans2=1;
        cin>>n>>m>>L>>v;
        for(int i=1;i<=n;i++)
        {
            cin>>d[i]>>vc>>a;
            if(vc>v)
            {
                l[num]=d[i];
                r[num]=L;
                num++;
            }
        }
        sort(l+1,l+num+1);
        int u=-1;
        for(int i=1;i<=m;i++)
        {
            cin>>p[i];
            u=max(u,p[i]);
        }
        ans=upper_bound(l+1,l+num+1,u)-l;
        int ll=l[1],rr=r[1];
        cout<<ans-2<<" ";
        if(ans==2)
        {
            cout<<m<<endl;
            continue;
        }
        for(int i=1;i<num;i++)
        {
            if(rr<l[i+1])
            {
                ans2++;
                rr=r[i+1];
            }
            else
            {
                ll=l[i];
            }
        }
        cout<<m-ans2<<endl;
    }
    return 0;
}
